package com.study.mike.model.entity;


import cn.hutool.core.date.DateTime;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author kh
 * @since 2021-12-29
 */
@Data
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @ExcelIgnore
    private Long id;

    /**
     * 姓名
     */
//    @SensitiveInfo(mode = MaskModeEnum.MID)
//    @Sensitive(type = SensitiveEnum.NAME)
    @NotNull(message = "用户名不能为空！")
    @ExcelProperty("姓名")
    private String name;


    @TableField(value = "name_encrypt")
    @ExcelIgnore
    private String nameEncrypt;

    /**
     * 年龄
     */
    @ExcelProperty("年龄")
    private Integer age;

    /**
     * 邮箱
     */
//    @Sensitive(type = SensitiveEnum.EMAIL)
//    @EncryptField
//    @SensitiveInfo(mode = MaskModeEnum.MID)
//    @SensitiveInfo(handler = CustomDataMaskHandler.class)
    @ExcelProperty("邮箱")
    private String email;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @ExcelProperty("创建时间")
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ExcelIgnore
    private Date modifyTime;

    /**
     * 逻辑删除判断
     */
    @TableLogic
    @ExcelIgnore
    private Boolean isDelete;

    /**
     * 乐观锁版本
     */
    @Version
    @ExcelIgnore
    private Integer version;

    /**
     * 手机号
     */
    @TableField(value = "phone")
//    @EncryptField
//    @Sensitive(type = SensitiveEnum.PHONE)
//    @SensitiveInfo(handler = CustomDataMaskHandler.class)
//    @Sensitive(type = SensitiveEnum.PHONE)
    @ExcelProperty("手机号")
    private String phone;

    /**
     * 脱敏姓名
     */
    @TableField(value = "name_sensitive")
    @ExcelIgnore
    private String nameSensitive;

    @TableField(value = "email_sensitive")
    @ExcelIgnore
    private String emailSensitive;

    @TableField(value = "pay_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ExcelIgnore
    private Date payTime;
}
